

function curry(fn)  {
    //第一个是fn，过滤掉
    let _args = [...arguments].slice(1)
    return (...args) => {  // args 接收新参数
        if (args.length === 0) {  // 参数args为空时，触发执行fn
            return fn(..._args)
        } else {  //  参数args不为空时，即继续添加参数
            return curry(fn,..._args,...args)
        }
    }
}


// 测试
let sum = (...arr) => {
    return arr.reduce((a=0, b=0) => {
        return a + b
    })
}

var sumPlus = curry(sum)(1)(2)
console.log(sumPlus())

//测试
let  show = (...arr) =>{
    console.log(...arr)
}

let showPlus = curry(show,1,2,3)('a')('b','c')


function fn(){
    return curry(show,1,2,3)('a')('b','c')()
}
fn()